// 题目链接：https://www.luogu.com.cn/problem/P1036

#include <iostream>

const int N = 30;

int n, k;
int res = 0;

int q[N];
int arr[N];

bool is_prime(int x)
{
    if (x < 2)
        return false;

    for (int i = 2; i <= x / i; ++i)
    {
        if (x % i == 0)
            return false;
    }

    return true;
}

void DFS(int start, int pos)
{
    if (pos > k)
    {
        int sum = 0;
        for (int i = 1; i <= k; ++i)
        {
            sum += arr[q[i]];
        }
        if (is_prime(sum))
            ++res;

        return;
    }

    for (int i = start; i <= n; ++i)
    {
        q[pos] = i;
        DFS(i + 1, pos + 1);

        // 恢复环境
        q[pos] = 0;
    }
}

int main()
{
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d", &arr[i]);
    }

    DFS(1, 1);

    printf("%d\n", res);

    return 0;
}